#!/usr/bin/env python
#coding=utf-8

"""
各种有用的技巧

域名查询ip
#>>> import socket
#>>> socket.gethostbyname('www.renren.com')
#'123.125.44.245'

反转
>>> 'abcd'[::-1]
'dcba'

"""

def exception1():
    try:
        a = b
    except Exception,data:
        print Exception,":",data
        
def exception2():
    import traceback 
    try:
        a = b
    except: 
        traceback.print_exc()
        
def exception3():
    import sys
    try:
        a = b
    except:
        info = sys.exc_info()
        print info

def pause():
    import os
    os.system("pause")

def addLock(someFunction):
    #线程安全
    import threading
    mylock = threading.RLock()
    mylock.acquire()
    someFunction()
    mylock.release()

